package logic

import (
	"context"
	"videos/videorpc/videorpc"

	"videos/api/internal/svc"
	"videos/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewVideoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoDetailLogic {
	return &VideoDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *VideoDetailLogic) VideoDetail(req *types.VideoDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	detail, err := l.svcCtx.VideoRpc.VideoDetail(l.ctx, &videorpc.VideoDetailRequest{
		VideoId: int64(req.VideoId),
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "视频详情展示成功",
		Code:    200,
		Data:    detail,
	}, nil
}
